package com.aoyy.util;

import java.util.List;
/**======================================================================
 * <code>Pagination</code> class is served as a pagination component
 * @author Administrator
 * @date 2017-07-12
 * ======================================================================= */
public class Pagination<T> {
  private Integer recordCount;
  private Integer pageNo = 1;
  private Integer pageSize = 10;
  private List<T> list;
  
  public void setRecordCount(Integer recordCount) {
	this.recordCount = recordCount;  
  }
  public Integer getRecordCount() {
	return recordCount;  
  }
  
  public void setPageNo(Integer pageNo) {
	this.pageNo = pageNo;  
  }
  public Integer getPageNo() {
	return pageNo;  
  }
  
  public void setPageSize(Integer pageSize) {
	this.pageSize = pageSize;  
  }
  public Integer getPageSize() {
	return pageSize;  
  }
  
  public void setList(List<T> list) {
	this.list = list;  
  }
  public List<T> getList() {
	return list;  
  }
  
  /**===================================================================
   * <code>getPages()<code> method is to get <code>pages</code>
   * @param {Integer} pageSize
   * @param {Integer} recordCount
   * @return {Integer} pages
   * ==================================================================== */
  public Integer getPages() {
	return (recordCount - 1) / pageSize + 1;  
  }
  
  public Integer getFirstPageNo() {
	return 1;  
  }
  
  public Integer getPreviousPageNo() {
	if (pageNo > 2) {
	  return pageNo - 1;	
	}
	return 1;
  }
  
  public Integer getNextPageNo() {
	if (pageNo < getPages()) {
      return pageNo + 1;		
	}
	return getPages();
  }
  
  public Integer getLastPageNo() {
	return getPages();  
  }
 
}
